//获取openid
wx.login({
  success: function(loginCode) {
    var appid = ''; //填写微信小程序appid
    var secret = ''; //填写微信小程序secret

    //调用request请求api转换登录凭证
    wx.request({
      url: '',
      header: {
        'content-type': 'application/json'
      },
      success: function(res) {
        console.log(res.data.openid) //获取openid
      }
    })
  }
})